// TOWN SCRIPT
//    Town 3: Portal Landing

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documentation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

body;

beginstate INIT_STATE;
// Called upon entering

if(get_flag(3,0) == 0) {
	message_dialog("When you awake, you are in a completely different place. From the looks of things, you are high up in the mountains. The sun is strong up here, and the lilacs seem in full bloom.","However, you feel a little uncomfortable, as if you are being watched...");
	set_flag(3,0,1);
	
	put_boom_on_char(0,2,0);
	put_boom_on_char(1,2,0);
	put_boom_on_char(2,2,0);
	put_boom_on_char(3,2,0);
	run_animation_sound(10);
}


	
		
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// Called every turn.

break;

//Reappraching portal
beginstate 10;
	
	if(get_flag(250,6) != 0) {
		message_dialog("You step through the portal, and black out again. When you wake up, you make your way out of the mountains, and towards Greenleaf.","");
		
		move_to_new_town(0,24,5);
	}
	message_dialog("You approach the centre of the teleportal, expecting to be torn apart again. However, aside from the air crackling a little, nothing happens. It appears that you won't be able to get back this way.","");
	block_entry(1);
break;

//Boulders
beginstate 11;
	message_dialog("You look at this boulder - it crackles menacingly as you lean closer. You aren't sure whether or not the material is magically-charged, or if somebody put an enchantment on it later.","You ponder on it for a second, before moving on. As interesting as it is, you have better things to occupy your mind.");
break;

beginstate 12;
	if(get_flag(250,6) != 0) {
		message_dialog("You should go through the portal and take Laurina home...","");
		block_entry(1);
	}
break;

beginstate 13;
	if(get_flag(250,6) == 1) {
		message_dialog("As you approach the portal, it suddenly bursts to life. Roxy stumbles through, late, as usual...","");
		
		force_view_center(17,13);
		force_instant_terrain_redraw();
		
		activate_hidden_group(1);
		put_boom_on_char(6,2,0);
		run_animation_sound(10);
		
		pause(2 * get_flag(250,5));
		
		message_dialog("She shakes her head to clear it, and then spots you, with Laurina. _Guys!_ she yells, and rushes over, embracing Laurina, and pumping your hands. _Way to go!_","");
		
		text_bubble_on_char(0,"Thanks."); 
		force_instant_terrain_redraw();
		pause(3 * get_flag(250,5));
			
		erase_text_bubbles();
		force_instant_terrain_redraw();
		
		text_bubble_on_char(0,"We're going back to Greenleaf."); 
		force_instant_terrain_redraw();
		pause(4 * get_flag(250,5));
			
		erase_text_bubbles();
		force_instant_terrain_redraw();
		
		text_bubble_on_char(0,"Coming?"); 
		force_instant_terrain_redraw();
		pause(4 * get_flag(250,5));
			
		erase_text_bubbles();
		force_instant_terrain_redraw();
		
		message_dialog("_Of course!_ Roxy beams, and steps through the portal again. All you have to do now is follow her...","");
		set_flag(250,6,2);
		
		put_boom_on_char(6,2,0);
		run_animation_sound(10);
		erase_char(6);
	}
break;
		